using System;
using System.Collections.Generic;
using System.Text;
using BusinessObjects.BO_Actions;
using Entity.StoreProcedure;
using BusinessObjects;
using System.Data;
namespace BusinessObjects.BO_GetObjects
{
    public static class BO_portal_guests
    {
        public static DataTable SelectAll()
        {
            try
            {
                usp_portal_guests_select_all entity = new usp_portal_guests_select_all();

                return BO_Actions<usp_portal_guests_select_all>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectTop(int rows)
        {
            try
            {
                usp_portal_guests_select_top entity = new usp_portal_guests_select_top();
                entity.NUMBERRECORD = rows;

                return BO_Actions<usp_portal_guests_select_top>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable Search(int guest_id)
        {
            try
            {
                usp_portal_guests_search entity = new usp_portal_guests_search();
                entity.GUEST_ID = guest_id;

                return BO_Actions<usp_portal_guests_search>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectWithPaged(int startIndex, int pageCount)
        {
            try
            {
                usp_portal_guests_select_paged entity = new usp_portal_guests_select_paged();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;

                return BO_Actions<usp_portal_guests_select_paged>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string Insert(string ip_address, string region, DateTime first_access_date, DateTime last_access_date, int total_access)
        {
            try
            {
                usp_portal_guests_insert entity = new usp_portal_guests_insert();
                entity.IP_ADDRESS = ip_address;
                entity.REGION = region;
                entity.FIRST_ACCESS_DATE = first_access_date;
                entity.LAST_ACCESS_DATE = last_access_date;
                entity.TOTAL_ACCESS = total_access;

                return BO_Actions<usp_portal_guests_insert>.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string Update(Int64 guest_id, string ip_address, string region, DateTime first_access_date, DateTime last_access_date, int total_access)
        {
            try
            {
                usp_portal_guests_update entity = new usp_portal_guests_update();
                entity.GUEST_ID = guest_id;
                entity.IP_ADDRESS = ip_address;
                entity.REGION = region;
                entity.FIRST_ACCESS_DATE = first_access_date;
                entity.LAST_ACCESS_DATE = last_access_date;
                entity.TOTAL_ACCESS = total_access;

                return BO_Actions<usp_portal_guests_update>.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectAdmin(string keyword, int startIndex, int pageCount)
        {
            try
            {
                usp_portal_guests_select_admin entity = new usp_portal_guests_select_admin();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.KEYWORDS = keyword;
                return BO_Actions<usp_portal_guests_select_admin>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable Delete(string guest_ids, int del_type)
        {
            try
            {
                usp_portal_guests_delete entity = new usp_portal_guests_delete();
                entity.DELETE_TYPE = del_type;
                entity.IDS = guest_ids;
                entity.SPLITER = ";";
                return BO_Actions<usp_portal_guests_delete>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}

